package ex2.pukepaiTEST01;

import java.util.*;

/**
 * @AUTHOR 尹书岿
 * @DATE 2024/12/10 19:35
 * @DESCRIBE
 */
public class Poker {
    //首先定义卡片数组和花色数组
    Card[] cards;
    String[] suits = {"红桃","黑桃","方片","梅花"};

    //将整副扑克存进去  注意利用for循环嵌套分开花色和数字
    public Poker(){
        cards = new Card[52];
        int index = 0;
        for (int i = 0; i < suits.length; i++){
            for (int j = 1; j <= 13; j++){
                Card card = new Card(suits[i],j);
                //将每张牌干进数组
                cards[index++] = card;
//                System.out.println(card);
            }
        }
    }

    //输出扑克
    public void outPutCard(){
        int index = 0;
        for (int i = 0; i < suits.length; i++){
            for (int j = 1; j <= 13; j++){
                System.out.print(cards[index++] + " ");
            }
            System.out.println();
        }
    }

    //洗牌
    public void shuffle(){
        Random random = new Random();
        for (int i = 0; i < 52 ; i++){
            int index = random.nextInt(52);
            Card temp = cards[i];
            cards[i] = cards[index];
            cards[index] = temp;
        }
    }

    //洗牌后得到的第一幅牌
    public List<Card> getOneHand(){
        List<Card> hand = new ArrayList<>();
        this.shuffle();
        for (int i = 0; i < 5 ;i++){
            hand.add(cards[i]);
        }
        return hand;
    }

    //判断各种牌的情况
    public String getHandType(List<Card> hand){
        Set<String> suitSet = new HashSet<>();
        Set<Integer> rankSet = new HashSet<>();
        List<Integer> rankList = new ArrayList<>();
        Map<Integer,Integer> CountMap = new HashMap<>();
        return "unknown";
    }




    public static void main(String[] args) {
        Poker poker = new Poker();
        poker.outPutCard();
        poker.shuffle();
        System.out.println();
        poker.outPutCard();

        List<Card> hand = poker.getOneHand();
        System.out.println(hand);
    }
}
